import { useRoutes } from "react-router-dom";
import HomePage from "@/pages/home";
import { lazy } from "react";
const Register = lazy(() => import("@/pages/register"));
const Login = lazy(() => import("@/pages/login"));
const ErrorPage = lazy(() => import("@/components/error/404.jsx"));
const Workbench = lazy(() => import("@/pages/home/rightPages/workbench"));
const OrderManagement = lazy(() => import("@/pages/home/rightPages/orderManagement"));
const ClassificationManagement = lazy(() => import("@/pages/home/rightPages/classificationManagement"));
const DishManagement = lazy(() => import("@/pages/home/rightPages/dishManagement"));
const PackageManagement = lazy(() => import("@/pages/home/rightPages/packageManagement"));
const Statistics = lazy(() => import("@/pages/home/rightPages/statistics"));
const EmployeeManagement = lazy(() => import("@/pages/home/rightPages/employeeManagement"));
const ScientificResearchManagementSystem = lazy(() => import("@/pages/home/rightPages/scientificResearchManagementSystem"));
// 路由映射表
const routerMap = [
  {
    path: "/",
    element: <HomePage />,
    errorElement: <ErrorPage />,
    children: [

      {
        index: true,
        element: <Workbench />,
      },
      {
        path: "workbench",
        element: <Workbench />,
      },
      {
        path: "orderManagement",
        element: <OrderManagement />,
      },
      {
        path: "classificationManagement",
        element: <ClassificationManagement />,
      },
      {
        path: "dishManagement",
        element: <DishManagement />,
      }, {
        path: "packageManagement",
        element: <PackageManagement />,
      },
      {
        path: "statistics",
        element: <Statistics />,
      },
      {
        path: "employeeManagement",
        element: <EmployeeManagement />,
      },
      {
        path: "scientificResearchManagementSystem",
        element: <ScientificResearchManagementSystem />,
      }
    ],
  },
  {
    path: "/login",
    element: <Login />,
    errorElement: <ErrorPage />,
  },
  {
    path: "/register",
    element: <Register />,
    errorElement: <ErrorPage />,
  },
  {
    path: "*",
    element: <ErrorPage />,
  },
];

function Router() {
  const routerTab = useRoutes(routerMap); //注册前端路由表

  return <div>{routerTab}</div>;
}
export default Router;